﻿using System;
using System.Diagnostics;
using System.Windows.Controls;
using System.Windows.Input;
using TheMovieDb.Example.ViewModels;

namespace TheMovieDb.Example.Views
{
    /// <summary>
    /// Interaction logic for PersonView.xaml
    /// </summary>
    public partial class PersonView
    {
        public PersonViewModel ViewModel
        {
            get { return DataContext as PersonViewModel; }
        }
        public PersonView()
        {
            InitializeComponent();
            ViewModel.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "IsBusy")
                {
                    Cursor = ViewModel.IsBusy ? Cursors.Wait : Cursors.Arrow;
                }
            };
        }

        private void TextBlockMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var tb = sender as TextBlock;
            if (tb == null)
                return;
            string url = tb.Tag.ToString();
            if (string.IsNullOrEmpty(url))
                return;
            try
            {
                Process.Start(url);
            }
            catch (Exception ex)
            {
                string mes = ex.Message;
            }
        }
    }
}
